//
//  WmcSettingBusinessItemView.swift
//  YPWatermarkCamera
//
//  Created by Json on 2023/7/6.
//

import UIKit

class WmcSettingBusinessItemView: WmcBaseView {
    /// 图标+标题+副标题
    private lazy var horStackView: UIStackView = {
        let stackV = UIStackView()
        stackV.axis = .horizontal
        stackV.spacing = 8.0
        stackV.distribution = .fill
        stackV.alignment = .center
        return stackV
    }()
    /// 图标
    private lazy var iconView: UIImageView = {
        let imgView = UIImageView()
        return imgView
    }()
    /// 标题+副标题
    private lazy var verStackView: UIStackView = {
        let stackV = UIStackView()
        stackV.axis = .vertical
        stackV.spacing = 2.0.wmc_autoHor
        stackV.distribution = .fill
        stackV.alignment = .fill
        return stackV
    }()
    
    /// 标题
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = 13.wmc_scaleFont(weight: .medium)
        label.textColor = UIColor.wmc_blackH1_000000
        return label
    }()
    /// 副标题
    private lazy var subTitleLabel: UILabel = {
        let label = UILabel()
        label.font = 13.wmc_scaleFont()
        label.textColor = UIColor.wmc_grayH8_8A8A99
        return label
    }()
    
    var title: String = "" {
        didSet {
            titleLabel.text = title
        }
    }
    
    var subTitle: String = "" {
        didSet {
            subTitleLabel.text = subTitle
        }
    }
    
    var image: UIImage? {
        didSet {
            iconView.image = image
        }
    }
    
    
    // MARK: UI
    
    override func makeUI() {
        super.makeUI()
        let hMargin = 12.0.wmc_autoHor
        let iconWH = 36.0.wmc_autoHor
        backgroundColor = UIColor.wmc_white_FFFFFF
        layer.cornerRadius = 8.0
        clipsToBounds = true
        // horStackView
        addSubview(horStackView)
        horStackView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(hMargin)
            make.right.equalToSuperview().offset(-hMargin)
            make.top.bottom.equalToSuperview()
        }
        // 图标
        horStackView.addArrangedSubview(iconView)
        iconView.snp.makeConstraints { make in
            make.width.height.equalTo(iconWH)
        }
        // verStackView
        horStackView.addArrangedSubview(verStackView)
        // 标题
        verStackView.addArrangedSubview(titleLabel)
        // 副标题
        verStackView.addArrangedSubview(subTitleLabel)
    }

}
